feat(pd): add bounded decode-capacity admission control - #1529
Open
sufubao wants to merge 9 commits into
Open
Conversation
sufubao
force-pushed
the
feat/pd-cache-aware-admission
branch
from
August 31, 2026 12:11
93312ef to
b915415
Compare
Collaborator
Author
|
极压回退修正已推送: 这次修正不再把 Radix cache 余量当作并发安全边界:
验证:104 项相关测试、200×500 随机状态转换以及 D=64 控制器饱和实验通过;GitHub pre-commit CI 已通过。控制器合成实验中,早期 cache-full 实现为 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景与根因
main中的 PD Master 在进行中请求数达到 Decode 容量时直接返回繁忙。本 PR 将它替换为有界、可取消的等待队列,并支持多 Master 容量切分、Session 优先级和nchoice 原子计费。早期实现曾把 Prefill Radix cache 余量换算成冷请求并发硬上限:
Radix cache 满是可驱逐缓存的正常稳态,不是 Decode 并发安全边界。但该公式会在 cache 满时把冷请求并发压到 1;准入租约又持有到完整 stream 结束,最终使大量冷请求串行化。同时,节点每个 TOKEN_PACK 都扫描 Radix 共享状态,进一步放大了高压控制面开销。
最终方案删除这两条路径:Decode 容量是唯一的全局并发硬约束;Session 和缓存命中只影响软优先级。
准入模型
n个 choice 原子占用n个 Decode 槽位;需求超过当前总容量时立即失败。--disable_pd_master_decode_capacity_limit继续用于完全绕过该准入队列。公平调度与 gang backfill
请求入队时分为三类:
CONTINUATION:服务端已观察到同一X-Session-Id的有效输出。PROBABLE_CACHE_HIT:cache-aware selector 估算的前缀命中率达到阈值。COLD:其余请求。调度采用按 Decode 槽位计费的 deficit round-robin,默认 quantum 为 8:3:1;多 choice 请求按实际槽位成本扣费。
当一个已选 gang 只因当前空闲槽位不足而阻塞时,后续可容纳请求可以做有限 backfill;累计 backfill 达到一个 Decode 波次后转为 reservation,停止绕过该 gang,避免大
n请求永久饥饿。队列已满时,当前唯一可运行的新请求仍可在 backfill 预算内填充物理空槽;它不扩大等待队列,不越过实际可运行的 DRR 对手,也不破坏 Session FIFO 或 gang reservation。这避免了同 Session waiter 或多个 gang 占满队列时 Decode 槽位空转。
同一 Session 严格串行和 FIFO,其他 Session 仍可继续调度。排队请求支持按优先级超时和任务取消;队列满时,高优先级请求可以替换较低优先级等待项。
缓存信号与热路径清理
capacity_share/capacity_epoch。多 Master 与滚动升级
running_max_req_size;稳态时各 Master 份额之和等于节点容量。capacity_epoch并立即唤醒心跳;旧 epoch 不会覆盖新份额。start_args保留键;旧节点连接新 Master 时仍回退到running_max_req_size。验证
PYTHONPATH=. exp -m "final PR1529 bounded decode admission regression suite" \ python -m pytest -q \ unit_tests/server/test_pd_admission.py \ unit_tests/server/test_pd_cache_aware.py \ unit_tests/server/test_pd_master_mode.py \ unit_tests/server/httpserver/test_pd_generate_error.py \ unit_tests/server/httpserver/test_pd_master_cached_tokens.py \ test/test_pd_selector/test_pd_master_multi_choice.py \ test/test_api/test_server_busy_handling.py104 项相关测试通过,覆盖:
nchoice 原子槽位、容量动态缩放和队列裁剪此外,提交前通过:
git diff --check和py_compile控制器级合成实验(每请求模拟 50 ms 服务时间):
这是 admission controller 合成实验,不是真实模型/GPU 端到端吞吐数据。
范围与未验证边界
X-Session-Id;现有benchmark_multiturn.py尚未发送该请求头,因此没有端到端验证该优先级。